from tools.base_page import BasePage


class Pullsetting(BasePage):
    def push_detail(self):
        pull_title = ('id', 'com.znb.zxx:id/notif_title')
        try:
            self.elements(pull_title)[0].click()
            self.page(self.index)
        except:
            print('通知列表没有内容')
            self.page(self.index)
        return True

    def push_setting(self):
        setting_locator = ("id", "setting_img")
        cancel_message = ('id', 'com.znb.zxx:id/cancel_all_message')
        ok_tv = ('id', 'com.znb.zxx:id/ok_tv')
        self.find(setting_locator).click()
        self.find(cancel_message).click()
        self.find(ok_tv).click()
        self.back_activity(1)

    def exist_push_list_is_not_clear(self):
        '''
        判断通知消息是否清空
        :return:
        '''
        message = ('xpath', '//*[@text="这里还没有消息~"]')
        if self.is_element(message):
            self.page(self.index)
            return True
        else:
            self.page(self.index)
            return False
